package com.hibase.core.rule.entity;

import com.hibase.core.rule.annotation.HibaseRuleMethod;
import lombok.Data;

import java.lang.reflect.Method;

/**
 * @author chenfeng
 * @version 1.0
 * @date 2021/11/24 10:33
 * @des https://gitee.com/cheershi
 */
@Data
public class RuleMethod {

    private Object bean;
    private Method method;
    private String alias;

    public static RuleMethod of(Object bean, Method method) {
        RuleMethod ruleMethod = new RuleMethod();
        // HibaseRuleMethod当前bean
        ruleMethod.bean = bean;
        // HibaseRuleMethod当前方法
        ruleMethod.method = method;
        HibaseRuleMethod annotation = method.getAnnotation(HibaseRuleMethod.class);
        ruleMethod.alias = annotation.alias();
        return ruleMethod;
    }
}
